home *** CD-ROM | disk | FTP | other *** search
- #ifdef lint
- static char *SCCSid = "%W% (NCSA) %G%";
- #endif
- /*
- * event.c
- * by Gaige B. Paulsen
- ****************************************************************************
- * Part of NCSA Telnet for the Macintosh *
- * *
- * Uses : *
- * TCP/IP kernel for NCSA Telnet *
- * by Tim Krauskopf *
- * with Macintosh code by Gaige B. Paulsen *
- * *
- * National Center for Supercomputing Applications *
- * 152 Computing Applications Building *
- * 605 E. Springfield Ave. *
- * Champaign, IL 61820 *
- * *
- * *
- ****************************************************************************
- *
- * Main Event loop code for NCSA Telnet for the Macintosh
- *
- * Called by:
- * maclook.c
- */
-
- /*
- * Files for inclusion.
- */
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
-
- #include <Controls.h>
- #include <Desk.h>
- #include <Dialogs.h>
- #include <DiskInit.h>
- #include <Events.h>
- #include <Fonts.h>
- #include <Menus.h>
- #include <Memory.h>
- #include <OSEvents.h>
- #include <OSUtils.h> /* for Juggler */
- #include <Packages.h>
- #include <Quickdraw.h>
- #include <Resources.h>
- #include <Script.h>
- #include <ToolUtils.h>
- #include <Windows.h>
-
- #include "configrec.h"
- #include "whatami.h"
- #include "VSkeys.h"
- #include "wind.h"
- #include "prefs.h"
- #include "user.h"
- #include "util.h"
- #include "bkgr.h"
- #include "maclook.h"
- #include "netevent.h"
- #include "vsinterf.h"
- #include "menu.h"
- #include "vrrgmac.h"
- #include "tekrgmac.h"
- #include "rsmac.h"
- #include "ser.h" /* BYU 2.4.15 MPW */
-
- #ifdef MPW
- #include "mpw.h"
- #endif
-
- /*
- * Event Auxilliary Defines
- */
-
- #define KCHR_resource 12000 /* BYU 2.4.12 */
-
- #define WaitEvents 10 /* Mouse and Keyboard Dn Events for the Wait4Mouse() */
- #define BScode 51 /* This is the Keycode for Backspace */
- #define KPlowest 65 /* This is the last code before the KP */
-
- #define switchEvt 1 /* Switching event (suspend/resume ) for app4evt */
-
- #define WAITTICKS 3L /* One (Half) now tenth now 1/20th second for the first try.... */
- /*
- * Font Height and width constants
- */
-
- #define Fwidth 6
-
-
-
- /*
- * Window constraints
- */
-
-
- #define MAXWINDOWWIDTH 18+Fwidth*80
-
- /*
- * Window Defines
- */
-
- #define NO_WINDOW 0
- #define DEC_WINDOW 1
- #define TEK_WINDOW 2
-
- /* Macro Defines */
- #define MACRO_IP 0xff /* Send IP number here */
- #define MACRO_LINES 0xfe /* Send # of lines here */
-
-
- /* need some menu defines for enableing/disableing the edit menu */
-
- #define NMENUS 8 /* We have NMENUS menus right now */
- #define Edit 2 /* Edit Menu's Position */
- #define EDundo 1
- #define EDcut 3
- #define EDcopy 4 /* Edit Menu: Copy */
- #define EDpaste 5 /* Edit Menu: Paste */
- #define EDclear 6 /* Edit Menu: Clear */
- #define EDcopyt 7 /* Edit Menu: Copy Table */
- #define EDmacros 9 /* Edit Menu: Macros */
- #define EDprefs 10 /* Edit Menu: Preferences */
-
- /*
- * ASCII character set defines
- */
-
- #define ESC 0x1b /* the escape character */
- #define BS 0x08 /* the backspace character */
- #define DEL 0x7f /* the delete character */
- #define CR 0x0d /* the carriage return character */
- #define LF 0x0a /* the line feed character */
- #define KILLCHAR 0x15 /* the character to kill the local line with */
-
- #define Edit 2 /* BYU 2.4.11 - Edit Menu's Position */
- #define EDcopy 4 /* BYU 2.4.11 - Edit Menu: Copy */
- #define EDcopyt 7 /* BYU 2.4.11 - Edit Menu: Copy Table */
-
- #define Fil 1 /* BYU 2.4.11 - File Menu's Position */
- #define FLprint 12 /* BYU 2.4.11 - File Menu: Print Selection */
-
- extern int RSTextSelected(); /* BYU 2.4.11 */
- extern void RScursblinkoff(); /* BYU 2.4.11 */
- extern void RScursblink(); /* BYU 2.4.11 */
- extern void DoTheMenuChecks();
- /*
- * Type declarations for Globals
- */
-
- EventRecord
- myEvent; /* Event Record for main loop */
- WindowPeek
- myfrontwindow=0L; /* window pointer for changing the pointer */
- GrafPtr
- whichWindow; /* window pointer for event loop */
- short /* BYU 2.4.11 */
- cursorBlink, /* BYU 2.4.11 - 0 = noblink, 1 = blink */
- cursorType, /* BYU 2.4.11 - 0 = block, 1 = underscore, 2 = vertical line */
- whichKCHR; /* BYU 2.4.12 */
- int
- myfronttype=NO_WINDOW, /* what kinda window is the front one */
- myfrontvs=0, /* what is the VS # of the window */
- ctrl=0x100, /* Key option to use as control */
- suspended=FALSE,/* Are we in the air??? */
- mapTilde=1, /* Mapping the Tilde, Mapping the Tilde, I'll go a Mapping the Tilde */
- code; /* code used in mouse operations */
- long
- JuggTicks; /* How many ticks to wait when Juggling */
- Handle hKCHR; /* BYU 2.4.12 - Handle for keyboard mapping stuff */
- RgnHandle
- myfrontRgn=0L; /* Handle to the region of the window to scope for stuff */
- Cursor
- *lastCursor=0L;
- char
- allthekeys[16]; /* Someplace to put the keymap */
-
- #if 0 /* BYU 2.4.12 */
- int langnum;
- #endif /* BYU 2.4.12 */
-
- extern MenuHandle myMenus[NMENUS];
- extern void AdjustMenus(),ftppi(); /* BYU */
-
- unsigned char *macro[10]; /* the wonderful macro package .... */
-
- /*
- * Declarations for constant variables
- */
-
- unsigned char kpxlate[2][62] =
- /* table for translating virtual scan codes to internal codes for
- special keys. */
- {
- { /* virtual key code */
- VSKP, /* $41 */
- VSRT, /* $42 (Mac+) */
- VSF4, /* $43 (ADB) */
- 0, /* $44 */
- VSKC, /* $45 (ADB std) */
- VSLT, /* $46 (Mac+) */
- VSF1, /* $47 */
- VSDN, /* $48 (Mac+) */
- 0, /* $49 */
- 0, /* $4A */
- VSF3, /* $4B (ADB) */
- VSKE, /* $4C */
- VSUP, /* $4D (Mac+) */
- VSKM, /* $4E */
- 0, /* $4F */
- 0, /* $50 */
- VSF2, /* $51 (ADB) */
- VSK0, /* $52 */
- VSK1, /* $53 */
- VSK2, /* $54 */
- VSK3, /* $55 */
- VSK4, /* $56 */
- VSK5, /* $57 */
- VSK6, /* $58 */
- VSK7, /* $59 */
- 0, /* $5A */
- VSK8, /* $5B */
- VSK9, /* $5C */
- 0, /* $5D */
- 0, /* $5E */
- 0, /* $5F */
- VSF10, /* $60 */ /* BYU 2.4.12 */
- VSF11, /* $61 */ /* BYU 2.4.12 */
- VSF12, /* $62 */ /* BYU 2.4.12 */
- VSF8, /* $63 */ /* BYU 2.4.12 - was VSF3 */
- VSF13, /* $64 */ /* BYU 2.4.12 */
- VSF14, /* $65 */ /* BYU 2.4.12 */
- 0, /* $66 */
- VSF16, /* $67 */ /* BYU 2.4.12 */
- 0, /* $68 */
- VSF18, /* $69 */ /* BYU 2.4.12 */
- 0, /* $6A */
- VSF19, /* $6B */ /* BYU 2.4.12 */
- 0, /* $6C */
- VSF15, /* $6D */ /* BYU 2.4.12 */
- 0, /* $6E */
- VSF17, /* $6F */ /* BYU 2.4.12 */
- 0, /* $70 */
- VSF20, /* $71 */ /* BYU 2.4.12 */
- VSHELP, /* $72 */ /* BYU 2.4.12 */
- VSHOME, /* $73 */ /* BYU 2.4.12 */
- VSPGUP, /* $74 */ /* BYU 2.4.12 */
- VSDEL, /* $75 (ADB ext) */ /* BYU 2.4.12 - was 0x7f */
- VSF9, /* $76 */ /* BYU 2.4.12 - was VSF4 */
- VSEND, /* $77 */ /* BYU 2.4.12 */
- VSF7, /* $78 */ /* BYU 2.4.12 - was VSF2 */
- VSPGDN, /* $79 */ /* BYU 2.4.12 */
- VSF6, /* $7A */ /* BYU 2.4.12 - was VSF1 */
- VSLT, /* $7B */
- VSRT, /* $7C */
- VSDN, /* $7D */
- VSUP /* $7E */
- },
- {
- VSKP, /* $41 */
- VSF4, /* $42 (Mac+) */
- VSF4, /* $43 (ADB) */
- 0, /* $44 */
- VSKC, /* $45 (ADB) */
- VSKC, /* $46 (Mac+) */
- VSF1, /* $47 */
- VSF2, /* $48 */
- 0, /* $49 */
- 0, /* $4A */
- VSF3, /* $4B */
- VSKE, /* $4C */
- VSF3, /* $4D */
- VSKM, /* $4E */
- 0, /* $4F */
- 0, /* $50 */
- VSF2, /* $51 */
- VSK0, /* $52 */
- VSK1, /* $53 */
- VSK2, /* $54 */
- VSK3, /* $55 */
- VSK4, /* $56 */
- VSK5, /* $57 */
- VSK6, /* $58 */
- VSK7, /* $59 */
- 0, /* $5A */
- VSK8, /* $5B */
- VSK9, /* $5C */
- 0, /* $5D */
- 0, /* $5E */
- 0, /* $5F */
- VSF10, /* $60 */ /* BYU 2.4.12 */
- VSF11, /* $61 */ /* BYU 2.4.12 */
- VSF12, /* $62 */ /* BYU 2.4.12 */
- VSF8, /* $63 */ /* BYU 2.4.12 - was VSF3 */
- VSF13, /* $64 */ /* BYU 2.4.12 */
- VSF14, /* $65 */ /* BYU 2.4.12 */
- 0, /* $66 */
- VSF16, /* $67 */ /* BYU 2.4.12 */
- 0, /* $68 */
- VSF18, /* $69 */ /* BYU 2.4.12 */
- 0, /* $6A */
- VSF19, /* $6B */ /* BYU 2.4.12 */
- 0, /* $6C */
- VSF15, /* $6D */ /* BYU 2.4.12 */
- 0, /* $6E */
- VSF17, /* $6F */ /* BYU 2.4.12 */
- 0, /* $70 */
- VSF20, /* $71 */ /* BYU 2.4.12 */
- VSHELP, /* $72 */ /* BYU 2.4.12 */
- VSHOME, /* $73 */ /* BYU 2.4.12 */
- VSPGUP, /* $74 */ /* BYU 2.4.12 */
- VSDEL, /* $75 (ADB ext) */ /* BYU 2.4.12 - was 0x7f */
- VSF9, /* $76 */ /* BYU 2.4.12 - was VSF4 */
- VSEND, /* $77 */ /* BYU 2.4.12 */
- VSF7, /* $78 */ /* BYU 2.4.12 - was VSF2 */
- VSPGDN, /* $79 */ /* BYU 2.4.12 */
- VSF6, /* $7A */ /* BYU 2.4.12 - was VSF1 */
- VSLT, /* $7B */
- VSRT, /* $7C */
- VSDN, /* $7D */
- VSUP /* $7E */
- }
- };
-
- extern SysEnvRec theWorld; /* BYU 2.4.12 - System Environment record */
-
- extern Rect
- dragRect; /* Where it is legal to drag ourselves */
-
- extern long
- SysScriptKeys,
- SysScriptIcon;
-
- extern WindRec
- console,
- ftplog,
- *screens;
-
- extern short slip_connection; /* BYU 2.4.16 */
-
- extern int
- numwindows, /* The number of windows now from Maclook */
- ginon,
- xferon,
- whichMenus,
- ScriptManager,
- Juggling, /* Are we Juggling????? */
- scrn;
- extern Cursor
- *graphcurs, /* Cursor when in graphic window */
- *gincurs, /* Cursor when in graphics input mode */
- *xfercurs, /* Cursor when in transfer mode */
- *normcurs, /* Cursor for non-transfer normal mode */
- *textcurs, /* Cursor for text mode */
- *poscurs, /* Cursor for positioning mode */
- *watchcurs; /* Cursor for time-taking operations */
-
- void optionKeys /* BYU 2.4.18 - put this procedure back in */
- (
- void
- )
- {
- int err;
-
- SysScriptKeys = GetScript(smRoman, smScriptKeys);
- SysScriptIcon = GetScript(smRoman, smScriptIcon);
-
-
- if (!(Prefs.optKeys && ScriptManager))
- return;
-
- err= SetScript( smRoman, smScriptKeys, 12000);
- if (err)
- return;
- err= SetScript( smRoman, smScriptIcon, 12000);
- if (err)
- return;
- KeyScript(smRoman);
-
- putln("OPTIONAL option key processing installed");
- }
-
- void optionKeysOff /* BYU 2.4.18 - put this procedure back in */
- (
- void
- )
- {
-
- int err;
-
- if (!ScriptManager)
- return;
-
- if (!Prefs.optKeys) return;
-
-
- err= SetScript( smRoman, smScriptKeys, SysScriptKeys);
- if (err)
- return;
- err= SetScript( smRoman, smScriptIcon, SysScriptIcon);
- if (err)
- return;
- /* KeyScript(smRoman); */
- }
-
- void setmacro /* Set macro number <n> to the value of s */
- (
- int n,
- unsigned char *s
- )
- {
- unsigned char *p;
- int num=0, pos=0, escape=0;
-
- if (n<0 || n>9)
- return;
-
- p=macro[n];
-
- while ( *s) {
- if (escape) {
- escape=0;
- switch (*s) {
- case 'i':
- if ( pos >0) {
- *p++=num;
- *p++=*s;
- pos=0;
- }
- *p++=MACRO_IP;
- break;
- case '#':
- if ( pos >0) {
- *p++=num;
- *p++=*s;
- pos=0;
- }
- *p++=MACRO_LINES;
- break;
- case 'n':
- if ( pos >0) {
- *p++=num;
- *p++=*s;
- pos=0;
- }
- *p++='\012';
- break;
- case 'r':
- if ( pos >0) {
- *p++=num;
- *p++=*s;
- pos=0;
- }
- *p++='\015';
- break;
- case 't':
- if ( pos >0) {
- *p++=num;
- *p++=*s;
- pos=0;
- }
- *p++='\t';
- break;
- case '"':
- if ( pos >0) {
- *p++=num;
- *p++=*s;
- pos=0;
- }
- *p++='\"';
- break;
-
-
- case '\\':
- if ( pos >0) {
- *p++=num;
- escape=1;
- pos=0;
- num=0;
- }
- else
- *p++='\\';
- break;
- default:
- if (*s <='9' && *s >='0' && pos <3) {
- num= num*8+( *s -'0');
- pos++;
- escape=1;
- }
- else {
- if (pos ==0 && num==0) {
- *p++='\\';
- *p++=*s;
- }
- else {
- *p++=num;
- pos= 0;
- s--; /* back up the buffer. */
- }
- }
- break;
- }
- }
- else {
- if (*s=='\\') {
- num=0;
- pos=0;
- escape=1;
- }
- else
- *p++=*s;
- }
- s++;
- }
-
- if (pos >0) *p++=num;
- *p=0;
- } /* setmacro */
-
- void initmacros
- (
- void
- )
- {
- int i;
-
- for (i=0; i<10 ; i++) {
- (Ptr) macro[i] = NewPtr(256);
- if (macro[i]== NULL) {
- OtherError("No space for macro storage", "Fatal error");
- quit();
- }
- setmacro( i, "");
- }
- }
-
- void initKeyBoardMapping(void) { /* BYU 2.4.13 */
- long myscript; /* BYU 2.4.13 */
- /* BYU 2.4.13 */
- /* First try to use the default System 7 keyboard mapping. /* BYU 2.4.13 */
- /* When that fails use the application's KCHR resource if /* BYU 2.4.13 */
- /* it's the only one in town. /* BYU 2.4.13 */
- /* BYU 2.4.13 */
- /* Release the previously selected resource. /* BYU 2.4.13 */
- if (hKCHR) /* BYU 2.4.13 */
- ReleaseResource(hKCHR); /* BYU 2.4.13 */
- /* BYU 2.4.13 */
- if (Prefs.systemKCHR) { /* BYU 2.4.18 */
- myscript = GetEnvirons(smKeyScript); /* BYU 2.4.18 */
- if (myscript && ScriptManager) { /* BYU 2.4.18 */
- whichKCHR = GetScript(myscript,smScriptKeys); /* BYU 2.4.18 */
- if (whichKCHR) /* BYU 2.4.18 */
- hKCHR = GetResource('KCHR',whichKCHR); /* BYU 2.4.18 */
- } /* BYU 2.4.18 */
- if (!hKCHR) { /* BYU 2.4.18 */
- whichKCHR = KCHR_resource; /* BYU 2.4.18 */
- hKCHR = GetResource('KCHR', whichKCHR); /* BYU 2.4.18 */
- } /* BYU 2.4.18 */
- } else { /* BYU 2.4.18 */
- /* BYU 2.4.18 */
- /* Use the application KCHR resource */ /* BYU 2.4.18 */
- whichKCHR = KCHR_resource; /* BYU 2.4.13 */
- hKCHR = GetResource('KCHR', whichKCHR); /* BYU 2.4.13 */
- /* BYU 2.4.13 */
- /* If mapping "option" to "control" is not active, or the /* BYU 2.4.13 */
- /* application KCHR resource has been removed, use the /* BYU 2.4.13 */
- /* system KCHR resource for mapping keys. /* BYU 2.4.13 */
- if (!hKCHR) { /* BYU 2.4.13 */
- myscript = GetEnvirons(smKeyScript); /* BYU 2.4.13 */
- if (myscript && ScriptManager) { /* BYU 2.4.13 */
- whichKCHR = GetScript(myscript,smScriptKeys); /* BYU 2.4.13 */
- if (whichKCHR) /* BYU 2.4.13 */
- hKCHR = GetResource('KCHR',whichKCHR); /* BYU 2.4.13 */
- } /* BYU 2.4.13 */
- } /* BYU 2.4.13 */
- } /* BYU 2.4.13 */
- /* BYU 2.4.13 */
- if (!hKCHR) /* BYU 2.4.13 */
- whichKCHR = 0; /* BYU 2.4.13 */
- }
-
- void initEvents
- (
- void
- )
- {
-
- initmacros();
-
- if (theWorld.systemVersion < 0x0700) /* BYU 2.4.18 */
- optionKeys(); /* BYU 2.4.18 */
-
- #if 0 /* BYU - disabled per Scott@NCSA */
- optionKeys();
- #endif
-
- FlushEvents(everyEvent - diskEvt,0); /* Don't Let 'em get off without seeing it. */
-
- JuggTicks=WAITTICKS;
-
- #if 0 /* BYU 2.4.15 - initialized in "environ.c" */
- Juggling = 0;
- #endif /* BYU 2.4.15 */
-
- mapTilde = Prefs.mapTilde;
- if (GetTrapAddress( 0x60) != GetTrapAddress( 0x9f) ) {
- Juggling = 1;
- putln("Juggling!"); /* BYU */
- WaitNextEvent(everyEvent, &myEvent, JuggTicks, 0L);
- WaitNextEvent(everyEvent, &myEvent, JuggTicks, 0L);
- }
-
- hKCHR = 0; /* BYU 2.4.13 */
- initKeyBoardMapping(); /* BYU 2.4.12 */
-
- #if 0 /* BYU 2.4.12 */
- else Juggling =0; /* BYU LSC - Currently only check for Juggler */
- putln("Done with initEvents()");
- #endif /* BYU 2.4.12 */
- }
-
- void JTime
- (
- int i
- )
- {
- if (i >= 0)
- JuggTicks = i;
- }
-
- int updateCursor
- (
- int force
- )
- {
- static long lastPoint;
- static int optwasdown;
- int optDown;
- long myPoint;
-
- if (myfrontwindow) { /* BYU 2.4.11 */
- SetPort((GrafPtr) myfrontwindow); /* BYU 2.4.11 */
- } else { /* BYU 2.4.11 */
- SetCursor(normcurs); /* BYU 2.4.11 */
- return(0); /* BYU 2.4.11 */
- } /* BYU 2.4.11 */
-
- GetMouse((Point *) &myPoint);
-
- GetKeys((KeyMap) allthekeys);
- optDown = allthekeys[7] &4;
-
- if ( (!force) && (myPoint == lastPoint) && (optDown ==optwasdown))
- return(0);
-
- if (force)
- lastCursor=0L;
- if (ginon) {
- if (lastCursor!= gincurs) {
- SetCursor( gincurs);
- lastCursor = gincurs;
- }
- return(1);
- }
-
- if (xferon && !optDown) {
- if (lastCursor!= xfercurs) {
- SetCursor( xfercurs);
- lastCursor = xfercurs;
- }
- return(1);
- }
-
- switch (myfronttype) {
- case DEC_WINDOW:
- if (RSmouseintext( myfrontvs, myPoint)) {
- if (optDown) { /* Option key is down */
- if (lastCursor !=poscurs) {
- lastCursor =poscurs;
- SetCursor(poscurs);
- }
- } else {
- if (lastCursor !=textcurs) {
- lastCursor =textcurs;
- SetCursor(textcurs);
- }
- }
- } else {
- if (lastCursor !=normcurs) {
- lastCursor =normcurs;
- SetCursor(normcurs);
- }
- }
- break;
- case TEK_WINDOW:
- LocalToGlobal((Point *) &myPoint);
- if (ptinrgn((Point *) &myPoint, myfrontwindow->contRgn)) {
- if (lastCursor !=graphcurs) {
- lastCursor =graphcurs;
- SetCursor(graphcurs);
- }
- } else {
- if (lastCursor !=normcurs) {
- lastCursor =normcurs;
- SetCursor(normcurs);
- }
- }
- break;
- case NO_WINDOW:
- default:
- if (force) {
- SetCursor( normcurs);
- lastCursor= normcurs;
- }
- }
- lastPoint=myPoint;
- optwasdown=optDown;
- return(0);
- }
-
- void NoWindow
- (
- void
- )
- {
- myfrontwindow=0L;
- myfronttype=NO_WINDOW;
- myfrontRgn=0L;
- updateCursor(1);
- }
-
- int sendmacro /* send macro number n */
- (
- int n
- )
- {
- unsigned char temp[300], *mp, *tp;
- extern unsigned char myipnum[4];
-
- if (n<0 || n>9) return(-1);
-
- tp = temp;
- mp = macro[n];
- while ( *mp) {
- if ( *mp==MACRO_IP) {
- sprintf(tp,"%d.%d.%d.%d", myipnum[0], myipnum[1], myipnum[2], myipnum[3]);
- tp+=strlen(tp);
- mp++;
- }
- else if ( *mp==MACRO_LINES) {
- sprintf(tp,"%d", VSgetlines( screens[scrn].vs));
- tp+=strlen(tp);
- mp++;
- }
- else if (screens[scrn].ftpstate) { /* BYU 2.4.16 */
- if (*mp == CR) { /* BYU 2.4.16 */
- parse( &screens[scrn],(unsigned char *) "\015\012",2); /* BYU 2.4.16 */
- screens[scrn].kbbuf[ screens[scrn].kblen++ ] = 0; /* BYU 2.4.16 */
- ftppi(screens[scrn].kbbuf); /* BYU 2.4.16 - ftp client */
- screens[scrn].kblen=0; /* BYU 2.4.16 */
- mp++; /* BYU 2.4.16 */
- } else { /* BYU 2.4.16 */
- screens[scrn].kbbuf[ screens[scrn].kblen++ ] = *mp; /* BYU 2.4.16 */
- parse( &screens[ scrn], mp++, 1); /* BYU 2.4.16 */
- } /* BYU 2.4.16 */
- } else *tp++=*mp++; /* BYU 2.4.16 */
- } /* BYU 2.4.16 */
- *tp=0; /* Gotta have a nul! */
- tp= temp;
-
- if (!screens[scrn].ftpstate && /* BYU 2.4.16 */
- (screens[scrn].connectionType == 0 || slip_connection)) { /* BYU 2.4.16 */
-
- netpush( screens[scrn].port); /* BYU 2.4.16 */
-
- if (screens[scrn].lmflag) /* need to flush buffer */ /* BYU 2.4.16 */
- { /* BYU 2.4.16 */
- netwrite(screens[scrn].port,screens[scrn].kbbuf,screens[scrn].kblen); /* BYU 2.4.16 */
- screens[scrn].kblen=0; /* BYU 2.4.16 */
- } /* BYU 2.4.16 */
- } /* BYU 2.4.16 */
-
- if (!screens[scrn].ftpstate) { /* BYU 2.4.16 */
- netwrite(screens[scrn].port, tp, strlen((char *) tp) ); /* BYU 2.4.16 */
-
- if (screens[scrn].echo)
- parse( &screens[scrn],tp, strlen((char *) tp) ); /* BYU 2.4.16 */
- } /* BYU 2.4.16 */
-
- return(0);
- }
-
- long InterpretMessage(EventRecord *event) { /* BYU 2.4.12 */
- long message; /* BYU 2.4.12 */
- long state=0; /* BYU 2.4.12 */
- short keycode; /* BYU 2.4.12 */
- /* BYU 2.4.12 */
- /* Default to the application KCHR resource. /* BYU 2.4.12 */
- /* If it is missing then try the current system resource. /* BYU 2.4.12 */
- /* BYU 2.4.12 */
- if (whichKCHR) /* BYU 2.4.12 */
- hKCHR = GetResource('KCHR', whichKCHR); /* BYU 2.4.12 */
- else /* BYU 2.4.12 */
- return(event->message); /* BYU 2.4.12 */
- /* BYU 2.4.12 */
- if (!hKCHR) { /* BYU 2.4.12 */
- message = event->message; /* BYU 2.4.12 */
- } else { /* BYU 2.4.12 */
- keycode = ((event->message>>8) & 0xff) | /* BYU 2.4.12 */
- (event->modifiers & 0xff00); /* BYU 2.4.12 */
- message = KeyTrans(*hKCHR, keycode, &state); /* BYU 2.4.12 */
- message = (message & 0xff) | (event->message & 0xff00); /* BYU 2.4.12 */
- } /* BYU 2.4.12 */
- /* BYU 2.4.12 */
- return(message); /* BYU 2.4.12 */
- } /* BYU 2.4.12 */
-
- void doKeys
- (
- void
- )
- {
- int ascii,code;
- unsigned char sendch;
- long menuEquiv;
- short enterkey =0;
-
- ObscureCursor();
-
- /* If the option key is not mapped to the control key /* BYU 2.4 12 */
- /* then map it per the KCHR resource /* BYU 2.4.12 */
- /* if ((!Prefs.optKeys) && (myEvent.modifiers & optionKey)) /* BYU 2.4.12 */
- /* myEvent.message = InterpretMessage(&myEvent); /* BYU 2.4.12 */
-
- /* Map all keys by the appropriate Script/KCHR resource. /* BYU 2.4.12 */
- myEvent.message = InterpretMessage(&myEvent); /* BYU 2.4.13 */
-
- ascii = myEvent.message & charCodeMask;
- code = (myEvent.message & keyCodeMask) >> 8;
- if ((myEvent.modifiers & cmdKey) && (menuEquiv = MenuKey(ascii))) {
- docommand(menuEquiv,myEvent.modifiers);
- return;
- }
-
- if ((myEvent.modifiers & ( optionKey | controlKey)) && (ascii==32))
- ascii=0; /* ASCII nul value for command-spacebar */
-
- if (myEvent.modifiers & cmdKey) {
- if (ascii==';' ) { /* debugging information on cmd-; */
- int i;
- char temp[50];
- for (i=0; i<numwindows; i++) {
- sprintf(temp, "[%d] %d (%d) %s", i,screens[i].port, screens[i].active, screens[i].machine);
- putln(temp);
- }
- }
- }
-
- if (screens[scrn].corpse)
- return;
-
- if (myEvent.modifiers & cmdKey) {
- if (ascii >='0' && ascii <='9' ) { /* handle key macros */
- sendmacro( ascii-'0');
- return;
- }
- }
-
- if (numwindows<1 || ((myEvent.modifiers & cmdKey ) && whichMenus))
- return;
-
- #if 0 /* BYU 2.4.12 */
- if (code == 0x77) { /* Flush on <end> */
- FlushNetwork(scrn);
- return;
- }
- #endif /* BYU 2.4.12 */
-
- if (!screens[scrn].ftpstate && (code >= KPlowest)) { /* BYU - Handle Keypad */
- int shifted;
- shifted = (myEvent.modifiers & shiftKey) != 0;
- if (theWorld.keyBoardType == envStandADBKbd) /* BYU 2.4.12 */
-
- if (code == 0x45)
- code = 0x4e;
- else if (code == 0x4e)
- code = 0x45;
- ascii = kpxlate[shifted][code - KPlowest];
- VSkbsend(screens[scrn].vs, (unsigned char) ascii, screens[scrn].echo);
- return;
- }
-
-
- /* BSD-like mapping.... if we don't want this, set chars to something >128 and it wont work */
- if (ascii == screens[scrn].TELstop) {
- screens[scrn].enabled = 0;
- return;
- }
-
- if (ascii == screens[scrn].TELgo) {
- screens[scrn].enabled = 1;
- return;
- }
-
-
-
- if (ascii == screens[scrn].TELip) {
- netpush(screens[scrn].port);
- netwrite(screens[scrn].port, "\377\364",2);
- screens[ scrn].timing = 1; /* set emulate to TMwait */
- netwrite(screens[scrn].port, "\377\375\006",3); /* send TM */
- if (screens[scrn].lmflag)
- screens[scrn].kblen=0;
- return;
- }
-
-
-
- ascii &= 0x7f; /* Don't allow those bluming option chars */
-
- if (ascii == '`' && mapTilde) ascii = ESC; /* Map '`' to ESC */
-
- if ((screens[scrn].bsdel) && (code==BScode)) ascii=DEL;
-
- if (myEvent.modifiers & (optionKey | cmdKey)) { /* Map control chars */
- if (ascii == ESC) /* the '`' remains the same */
- ascii = '`';
- else
- if (code == BScode) { /* Swap only the true bksp */
- if (screens[scrn].bsdel) ascii=BS;
- else ascii=DEL;
- }
- else {
- if (Prefs.optKeys || !Prefs.cmdKeys) /* Option or command remapped to control */
- ascii &= 0x1f; /* All other chars are ctrl */
- }
- }
-
-
- if (screens[scrn].ftpstate) /* BYU - ftpclient */
- { /* BYU */
- if (ascii>31 && ascii <127 && code<KPlowest) /* BYU - add these chars to buffer */
- { /* BYU */
- if (screens[scrn].kblen < (MAXKB -1)) /* BYU - Add to buffer if not full */
- { /* BYU */
- screens[scrn].kbbuf[ screens[scrn].kblen++ ] = ascii; /* BYU */
- sendch=ascii; /* BYU */
- parse( &screens[ scrn], &sendch, 1); /* BYU */
- } /* BYU */
- else /* BYU */
- SysBeep(4); /* BYU - buffer full */
- } /* BYU */
- else /* BYU - not printable char */
- { /* BYU */
- if ( code == BScode ) /* BYU */
- { /* BYU */
- if (screens[scrn].kblen>0) /* BYU */
- { /* BYU */
- screens[scrn].kblen--; /* BYU */
- parse( &screens[scrn],"\010 \010",3); /* BYU */
- } /* BYU */
- } /* BYU */
- else if (ascii == CR) /* BYU */
- { /* BYU */
- parse( &screens[scrn],"\015\012",2); /* BYU */
- screens[scrn].kbbuf[ screens[scrn].kblen++ ] = 0; /* BYU */
- ftppi(screens[scrn].kbbuf); /* BYU - ftp client */
- screens[scrn].kblen=0; /* BYU */
- } /* BYU */
- else if (ascii == KILLCHAR) /* BYU */
- { /* BYU */
- while (screens[scrn].kblen >0) /* BYU */
- { /* BYU */
- parse( &screens[scrn],"\010 \010",3); /* BYU */
- screens[scrn].kblen--; /* BYU */
- } /* BYU */
- }
- }
- return; /* BYU */
- }
-
- else if (screens[scrn].lmflag) /* I'm in line-Mode... aren't you?? */
- {
- if (screens[scrn].echo && ! screens[scrn].halfdup) /* Handle local ECHOs */
-
- if (ascii>31 && ascii <127 && code<KPlowest) /* add these chars to buffer */
- {
- if (screens[scrn].kblen < (MAXKB -1)) /* Add to buffer if not full */
- screens[scrn].kbbuf[ screens[scrn].kblen++ ] = ascii;
- else
- {
- netwrite( screens[scrn].port, screens[scrn].kbbuf, screens[scrn].kblen); /* if full send buffer */
- screens[scrn].kbbuf[0]=ascii;
- screens[scrn].kblen=1;
- }
-
- sendch=ascii;
- parse( &screens[ scrn], &sendch, 1);
- if (!screens[scrn].halfdup)
- return; /* OK, were set...*/
-
- }
- else /* not printable char */
- {
- if ( code == BScode )
- {
- if (screens[scrn].kblen>0)
- {
- screens[scrn].kblen--;
- parse( &screens[scrn],"\010 \010",3);
- }
- return;
- }
- else if (ascii == CR)
- {
- char tt[50];
-
- netwrite( screens[scrn].port, screens[scrn].kbbuf, screens[scrn].kblen);
- sprintf(tt,"length %i ",(int)screens[scrn].kblen);
- putln(tt);
- screens[scrn].kblen=0;
- }
-
- else if (ascii == KILLCHAR)
- {
- while (screens[scrn].kblen >0)
- {
- parse( &screens[scrn],"\010 \010",3);
- screens[scrn].kblen--;
- }
- return;
- }
-
- else if (code <KPlowest)
- {
- netwrite( screens[scrn].port, screens[scrn].kbbuf, screens[scrn].kblen); /* if full send buffer */
- screens[scrn].kblen=0;
-
- if (ascii !=CR)
- {
- char crapp[5];
-
- if (ascii == 26) /* job control */
- {
- sprintf(crapp,"%c%c",255,237);
- netwrite(screens[scrn].port,crapp,2);
- parse( &screens[scrn],"^",1);
- parse( &screens[scrn], &sendch, 1);
- return;
-
- }
- sendch='@'+ascii;
- parse( &screens[scrn],"^",1);
- parse( &screens[scrn], &sendch, 1);
- }
- }
- }
- }
-
-
- else /* BYU = was: if (!screens[scrn].lmflag ) */
- {
- if (screens[scrn].echo && ! screens[scrn].halfdup) /* Handle local ECHOs */
- if (ascii>31 && ascii <127 && code<KPlowest)
- {
- if (screens[scrn].kblen < (MAXKB -1)) /* Add to buffer if not full */
- screens[scrn].kbbuf[ screens[scrn].kblen++ ] = ascii;
- else
- {
- netwrite( screens[scrn].port, screens[scrn].kbbuf,
- screens[scrn].kblen); /* if full send buffer */
- screens[scrn].kbbuf[ 0 ]=ascii;
- screens[scrn].kblen=1;
- }
- sendch=ascii;
- parse( &screens[ scrn], &sendch, 1);
- if (!screens[scrn].halfdup)
- return; /* OK, were set...*/
- }
- else
- {
- if ( code == BScode )
- {
- if (screens[scrn].kblen>0)
- {
- screens[scrn].kblen--;
- parse( &screens[scrn],"\010 \010",3);
- }
- return;
- }
- else if (ascii == KILLCHAR)
- {
- while (screens[scrn].kblen >0)
- {
- parse( &screens[scrn],"\010 \010",3);
- screens[scrn].kblen--;
- }
- return;
- }
-
- else if (code <KPlowest)
- {
- netwrite( screens[scrn].port, screens[scrn].kbbuf,
- screens[scrn].kblen); /* if full send buffer */
- screens[scrn].kblen=0;
- if (ascii !=CR)
- {
- sendch='@'+ascii;
- parse( &screens[scrn],"^",1);
- parse( &screens[scrn], &sendch, 1);
- }
- }
- }
- }
-
-
-
-
- if (ascii == '\015') /* BYU 2.4.18 - changed \n to \015 */
- { /* Map CR->CRLF */
- netpush( screens[scrn].port);
- if ((!screens[scrn].lmflag) || (!screens[scrn].crmap)) netwrite(screens[scrn].port,"\015",1);
- ascii=screens[scrn].crmap;
- if (screens[scrn].echo) parse( &screens[scrn],"\012\015",2);
- if (screens[scrn].connectionType && !slip_connection) /* BYU 2.4.18 */
- return; /* BYU 2.4.18 */
- }
-
- #ifdef OLD_STUFF
- if (ascii == '\r')
- {
- netwrite(screens[scrn].port,"\r",1);
- netpush(screens[scrn].port);
- ascii = screens[scrn].crmap;
- if (screens[scrn].echo) parse (&screens[scrn],"\r\012",2);
- }
- #endif
-
- if (screens[scrn].echo && screens[scrn].halfdup)
- {
- sendch=ascii;
- parse( &screens[scrn], &sendch, 1);
- }
-
- sendch= ascii;
- netwrite(screens[scrn].port,&sendch,1);
- netpush(screens[scrn].port); /* DAMN PYRAMIDS! */
-
- }
-
- void DoEvents
- (
- void
- )
- {
- Boolean gotOne; /* Did we get an event */
- int vs; /* BYU 2.4.11 */
-
- if (Juggling)
- gotOne = WaitNextEvent(everyEvent, &myEvent, JuggTicks, 0L);
- else
- {
- SystemTask(); /* love those desk acc. */
- gotOne = GetNextEvent(everyEvent, &myEvent);
- }
-
- if (gotOne) {
-
- /* BYU 2.4.11 - Turn the cursor off when the human makes the slightest move. */
- if (cursorBlink) { /* BYU 2.4.11 */
- whichWindow = FrontWindow(); /* BYU 2.4.11 */
- if ( (vs=RSfindvwind(whichWindow)) >= 0) /* BYU 2.4.11 */
- if (vs == screens[scrn].vs) /* BYU 2.4.11 */
- if (!(myEvent.modifiers & cmdKey) && /* BYU 2.4.18 */
- ((myEvent.what == keyDown) || /* BYU 2.4.18 */
- (myEvent.what == autoKey))) /* BYU 2.4.18 */
- RScursblinkon(vs); /* BYU 2.4.18 */
- else /* BYU 2.4.18 */
- RScursblinkoff(vs); /* BYU 2.4.18 */
- } /* BYU 2.4.11 */
-
- switch(myEvent.what) {
- case mouseDown:
- code = findwindow(pass(myEvent.where), &whichWindow);
- switch (code) {
- case inMenuBar:
- docommand(menuselect(pass(myEvent.where)),myEvent.modifiers);
- break;
- case inSysWindow:
- SystemClick(&myEvent, whichWindow);
- break;
- case inGoAway:
- if (trackgoaway( whichWindow, pass(myEvent.where))) {
- if (RSfindvwind(whichWindow)>=0) {
- int i;
- extern int findbyWind ();
-
- i=findbyWind( whichWindow); /* We need to know who */
- if (i>=0) {
- if ( screens[i].corpse)
- destroyport(i);
- else {
- if ( !ReallyClose( i) ) break;
- netclose(screens[i].port);
- destroyport(i);
- }
- }
- NoWindow();
- }
- else if (MacRGfindwind( whichWindow) >=0) {
- int i;
- i= MacRGfindwind( whichWindow);
- MacRGdestroy( i);
- NoWindow();
- }
- else {
- destroyGraphics( RGgetVG(whichWindow));
- NoWindow();
- }
- }
- break;
- case inDrag:
- if ((whichWindow != FrontWindow()) &&
- (!(myEvent.modifiers & cmdKey)) &&
- (!(myEvent.modifiers & optionKey))) {
- SelectWindow(whichWindow);
- }
- dragwindow(whichWindow, pass(myEvent.where), &dragRect);
- break;
- case inZoomIn:
- case inZoomOut:
- if (TrackBox( whichWindow, myEvent.where, code))
- RSzoom( whichWindow, code, myEvent.modifiers & shiftKey);
- break;
- case inGrow:
- RSsize( whichWindow, (long *) &myEvent.where, myEvent.modifiers);
- break;
- case inContent:
- if (whichWindow != FrontWindow()) {
- SelectWindow(whichWindow);
- }
- else
- if (RSclick( whichWindow, (long *) &myEvent.where,
- (myEvent.modifiers & shiftKey),
- (myEvent.modifiers & optionKey)) <0) {
- SetPort(whichWindow);
- GlobalToLocal(&myEvent.where);
- RGmousedown(whichWindow, &myEvent.where );
- }
- break;
- default:
- break;
- }
- break;
-
- case updateEvt:
- if (RSupdate((GrafPtr) myEvent.message))
- if (MacRGupdate((WindowPtr) myEvent.message))
- if (RGupdate((GrafPtr) myEvent.message) ==0)
- TekDisable(RGgetVG((GrafPtr) myEvent.message));
- break;
-
- case keyDown:
- case autoKey:
- doKeys(); /* All key events are processed through here */
- break;
-
- case diskEvt: /* check to see if disk needs to be initialized */
- myEvent.where.h = 100; myEvent.where.v = 120;
- if (noErr != (( myEvent.message >> 16 ) & 0xffff )) { /* check hi word */
- DILoad();
- dibadmount( &myEvent.where, myEvent.message);
- DIUnload();
- }
- break;
-
- case activateEvt:
- if ((myEvent.modifiers & activeFlag)==1) {
- int i;
-
- putln("enable event");
- AdjustMenus();
- DrawMenuBar();
- i=findbyWind((GrafPtr) myEvent.message); /* We need to know who */
- if (i>=0) {
- if ((screens[i].curgraph>-1) && (!(myEvent.modifiers & optionKey)))
- detachGraphics(screens[i].curgraph);
- changeport(scrn,i);
- scrn=i;
- }
- if ((i=RSfindvwind((GrafPtr) myEvent.message))>=0) {
- if (RSTextSelected(i)) { /* BYU 2.4.11 */
- EnableItem(myMenus[Fil],FLprint); /* BYU 2.4.11 */
- EnableItem(myMenus[Edit],EDcopy); /* BYU 2.4.11 */
- EnableItem(myMenus[Edit],EDcopyt); /* BYU 2.4.11 */
- } else { /* BYU 2.4.11 */
- DisableItem(myMenus[Fil],FLprint); /* BYU 2.4.11 */
- DisableItem(myMenus[Edit],EDcopy); /* BYU 2.4.11 */
- DisableItem(myMenus[Edit],EDcopyt); /* BYU 2.4.11 */
- } /* BYU 2.4.11 */
- RSactivate(i);
- myfrontwindow=(WindowPeek) myEvent.message;
- myfronttype=DEC_WINDOW;
- myfrontvs = i;
- myfrontRgn =0L;
- updateCursor(1);
- } else {
- myfrontwindow=(WindowPeek) myEvent.message;
- myfronttype=TEK_WINDOW;
- myfrontRgn =0L;
- updateCursor(1);
- if ( (i = RGgetdnum((GrafPtr) myEvent.message)) >-1) {
- if (( i = RGgetVS( i)) >-1) {
- EnableItem(myMenus[Fil],FLprint); /* BYU 2.4.11 - enable printing */
- EnableItem(myMenus[Edit],EDcopy); /* BYU 2.4.11 - enable copying */
- DisableItem(myMenus[Edit],EDcopyt); /* BYU 2.4.11 */
- i = findbyVS( i);
- changeport(scrn,i);
- scrn=i;
- }
- }
- }
- } else {
- int i;
-
- putln("disable event");
- AdjustMenus();
- DrawMenuBar();
- if ((i=RSfindvwind((GrafPtr) myEvent.message))>=0)
- RSdeactivate(i);
- NoWindow();
- }
- break;
- case app4Evt:
- switch(( myEvent.message >>24) &0xff) { /* App4 is a multi-event event */
- case switchEvt:
- if (myEvent.message & 0x20)
- /*Convert clipboard here if necc. (it is not)*/;
-
- if (myEvent.message & 0x1) { /* Resume Event */
- GrafPtr window;
- /* int vs; /* BYU 2.4.11 - defined above. */
-
- putln("resume");
- suspended = FALSE; /* We are no longer in suspension */
- DisableItem( myMenus[Edit],EDcut);
- DisableItem( myMenus[Edit],EDundo);
- DisableItem( myMenus[Edit],EDclear);
-
- initKeyBoardMapping(); /* BYU 2.4.12 - keyboard changed? */
-
- if (theWorld.systemVersion < 0x0700) /* BYU 2.4.18 */
- optionKeys(); /* BYU 2.4.18 */
-
- window = FrontWindow(); /* Who's on first */
- if ( (vs=RSfindvwind(window)) >= 0) {
- RSactivate(vs);
- myfrontwindow = (WindowPeek) window;
- myfronttype=DEC_WINDOW;
- myfrontvs = vs;
- myfrontRgn =0L;
- updateCursor(1);
- } else if ( (long)window != 0L) {
- myEvent.message = (long) window;
- myEvent.modifiers |= activeFlag;
- myEvent.what = activateEvt;
- myEvent.when = TickCount();
- SystemEvent( &myEvent);
- }
- }
- else { /* Suspend Event */
- GrafPtr window;
- /* int vs; /* BYU 2.4.11 - defined above. */
-
- putln( "suspend");
- suspended=TRUE; /* We be in waitin' */
- EnableItem( myMenus[Edit],EDcut);
- EnableItem( myMenus[Edit],EDundo);
- EnableItem( myMenus[Edit],EDclear);
-
- if (theWorld.systemVersion < 0x0700) /* BYU 2.4.18 */
- optionKeysOff(); /* BYU 2.4.18 */
-
- window = FrontWindow(); /* Who's on first */
- if ((window = FrontWindow())) {
- if ( (vs=RSfindvwind(window)) >= 0)
- RSdeactivate(vs);
- else if ( (long)window != 0L) {
- myEvent.message = (long) window;
- myEvent.modifiers &= (~activeFlag);
- myEvent.what = activateEvt;
- myEvent.when = TickCount();
- SystemEvent( &myEvent);
- }
- }
- NoWindow();
- }
- break; /* switch of myEvent.message >>24 */
- }
- break;
- }
-
- } else if (cursorBlink && !suspended) { /* BYU 2.4.11 */
- whichWindow = FrontWindow(); /* BYU 2.4.11 */
- if ( (vs=RSfindvwind(whichWindow)) >= 0) /* BYU 2.4.11 */
- if (vs == screens[scrn].vs) /* BYU 2.4.11 */
- RScursblink(vs); /* BYU 2.4.11 */
- } /* BYU 2.4.11 */
- updateCursor(0);
- }
-
- void Wait4Mouse
- (
- void
- )
- {
- EventRecord myEvent;
-
- while(!EventAvail(WaitEvents,&myEvent))
- {
- DoModem(); /* BYU 2.4.15 */
- Stask();
- #if 0 /* BYU 2.4.15 */
- DoNetEvents(); /* BYU 2.4.15 */
- #endif /* BYU 2.4.15 */
- #if 0 /* BYU 2.4.15 */
- rftpd(0);
- #endif /* BYU 2.4.15 */
- } /* while */
- FlushEvents( WaitEvents, 0 );
- }
-
- void WaitSeconds /* BYU 2.4.15 */
- ( /* BYU 2.4.15 */
- int myseconds /* BYU 2.4.15 */
- ) /* BYU 2.4.15 */
- { /* BYU 2.4.15 */
- long mytime = TickCount() + 60 * myseconds; /* BYU 2.4.15 */
- /* BYU 2.4.15 */
- while(mytime > TickCount()) /* BYU 2.4.15 */
- { /* BYU 2.4.15 */
- DoModem(); /* BYU 2.4.15 */
- Stask(); /* BYU 2.4.15 */
- DoNetEvents(); /* BYU 2.4.15 */
- } /* while */ /* BYU 2.4.15 */
- FlushEvents( WaitEvents, 0 ); /* BYU 2.4.15 */
- } /* BYU 2.4.15 */
-
- int getmacro
- (
- int n,
- unsigned char *dest
- )
- {
- unsigned char *s;
-
- if (n<0 || n>9)
- return(-1);
-
- s = macro[n];
- while (*s) {
- switch( *s) {
- case MACRO_IP :
- *dest++='\\';
- *dest++='i';
- break;
- case MACRO_LINES :
- *dest++='\\';
- *dest++='#';
- break;
- case '\\':
- *dest++='\\';
- *dest++='\\';
- break;
- case '\015':
- *dest++='\\';
- *dest++='r';
- break;
- case '\012':
- *dest++='\\';
- *dest++='n';
- break;
-
- #ifdef OLD_CRAP
- case '\015':
- s++;
- if (*s == '\012' || *s=='\000') {
- *dest++='\\';
- *dest++='n';
- }
- else {
- *dest++='\\';
- *dest++='0';
- *dest++='1';
- *dest++='5';
- s--;
- }
- break;
- #endif
- case '\t':
- *dest++='\\';
- *dest++='t';
- break;
- default:
- if ( isprint(*s))
- *dest++=*s;
- else {
- *dest++='\\';
- *dest++= (*s / 64) +'0';
- *dest++= ((*s % 64) / 8)+'0';
- *dest++= (*s % 8) +'0';
- }
- break;
- }
- s++;
- }
- *dest=0;
- return( 0);
- }
-